package com.ruoyi.web.controller.hotel;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hotel.domain.HotelHouseType;
import com.ruoyi.hotel.service.IHotelHouseTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 房型设置Controller
 *
 * @author sunye
 * @date 2024-11-15
 */
@RestController
@RequestMapping("/hotel/houseType")
@Api(tags = "房型设置")
public class HotelHouseTypeController extends BaseController
{
    @Autowired
    private IHotelHouseTypeService hotelHouseTypeService;

    /**
     * 查询房型设置列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:houseType:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询房型设置列表")
    public TableDataInfo list(HotelHouseType hotelHouseType)
    {
        startPage();
        List<HotelHouseType> list = hotelHouseTypeService.selectHotelHouseTypeList(hotelHouseType);
        return getDataTable(list);
    }


    /**
     * 查询所有房型设置列表
     */
    @GetMapping("/allList")
    @ApiOperation(value = "查询所有楼层列表")
    public AjaxResult allList(HotelHouseType hotelHouseType)
    {
        List<HotelHouseType> list = hotelHouseTypeService.selectHotelHouseTypeList(hotelHouseType);
        return success(list);
    }

    /**
     * 导出房型设置列表
     */
    @PreAuthorize("@ss.hasPermi('hotel:houseType:export')")
    @Log(title = "房型设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelHouseType hotelHouseType)
    {
        List<HotelHouseType> list = hotelHouseTypeService.selectHotelHouseTypeList(hotelHouseType);
        ExcelUtil<HotelHouseType> util = new ExcelUtil<HotelHouseType>(HotelHouseType.class);
        util.exportExcel(response, list, "房型设置数据");
    }

    /**
     * 获取房型设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotel:houseType:query')")
    @GetMapping(value = "/{houseTypeId}")
    public AjaxResult getInfo(@PathVariable("houseTypeId") Long houseTypeId)
    {
        return success(hotelHouseTypeService.selectHotelHouseTypeByHouseTypeId(houseTypeId));
    }

    /**
     * 新增房型设置
     */
    @PreAuthorize("@ss.hasPermi('hotel:houseType:add')")
    @Log(title = "房型设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelHouseType hotelHouseType)
    {
        hotelHouseType.setCreateId(getUserId());
        return toAjax(hotelHouseTypeService.insertHotelHouseType(hotelHouseType));
    }

    /**
     * 修改房型设置
     */
    @PreAuthorize("@ss.hasPermi('hotel:houseType:edit')")
    @Log(title = "房型设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelHouseType hotelHouseType)
    {
        hotelHouseType.setUpdateId(getUserId());
        return toAjax(hotelHouseTypeService.updateHotelHouseType(hotelHouseType));
    }

    /**
     * 删除房型设置
     */
    @PreAuthorize("@ss.hasPermi('hotel:houseType:remove')")
    @Log(title = "房型设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{houseTypeIds}")
    public AjaxResult remove(@PathVariable Long[] houseTypeIds)
    {
        return toAjax(hotelHouseTypeService.deleteHotelHouseTypeByHouseTypeIds(houseTypeIds));
    }
}
